<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-nested" prefix="nested" %>


<html:form action="/worksheet" >
   <script type="text/javascript" src="<%=request.getContextPath()%>/javascript/movetop.js"></script>
   <table border="0" align="center" width="75%" bordercolor="green">
       <tr>
           <td class="title">Worksheets</td>
       </tr> 
       <tr>
           <td>&nbsp;</td>
       </tr> 
       <tr>
           <td class="description-small">
           		<ul>
           			<li>Displayed worksheets are in pdf &nbsp;<img align="top" src="<%=request.getContextPath()%>/image/acrobaticon.gif" border="0"/> format.</li>
           			<li>Select/Change grade and subject to see the available worksheet(s).</li>
           		</ul>
           </td>
       </tr>        
       <tr>
           <td align="center">
              <table width="100%" border="0" bordercolor="red">
                 <bean:define id="grades" name="wiaform" property="grades" type="java.util.List" />
                 <bean:define id="subjects"   name="wiaform" property="subjects" type="java.util.List" />
                 <tr>
                 	<td width="10%">&nbsp;</td>
                    <td width="15%" class="formLabel">
                        Grade:
                    </td>
                    <td width="2%">&nbsp;</td>
                    <td width="20%">
	                  <html:select property="selectedGrade" onchange="getWorkSheets()">
	                      <html:options collection="grades" property="key" labelProperty="value" />
	                  </html:select>
                    </td>
                    <td width="15%" class="formLabel">Subject</td>
                    <td width="2%">&nbsp;</td>
                    <td width="20">
	                  <html:select property="selectedSubject" onchange="getWorkSheets()">
	                      <html:options collection="subjects" property="key" labelProperty="value" />
	                  </html:select>
                    </td>
                    <td width="16%">&nbsp;</td>
                 </tr>
              </table>
           </td>
       </tr>        
       <tr>
           <td><hr></td>
       </tr> 
       <logic:notEmpty name="wiaform" property="alluniquewsdata">
       <tr>
           <td>
           		<table width="100%" border="1" cellspacing="0" cellpadding="0" bordercolor="#e7e7e7">
           	   		<tr>
           	   			<td colspan="2" class="tableheadercenter">
           	   				Available worksheets in the selected grade and subject = <bean:write name="wiaform" property="availableWorkSheetCount"/>
           	   			</td>
           	   		</tr>
           	   		<tr>
           	   			<td colspan="2">&nbsp;</td>
           	   		</tr>
           	   		<bean:define name="wiaform" property="alluniquewsdata" id="topics"/>
           	   		<logic:iterate id="mapentry" name="topics">
           	   		<tr>
           	   			<td width="20%" valign="top" class="tablesubheaderright">
           	   				<bean:write name="mapentry" property="key"/>
           	   			</td>
           	   			<td width="80%">
           	   				<table width="100%" border="0" cellspacing="0" cellpadding="2">
           	   				<logic:iterate id="typemapentry" name="mapentry" property="value">
           	   					<bean:define name="typemapentry" property="key" id="type"/>
           	   					<tr>
           	   					 	<td width="50%" class="rightlabel" valign="top">
           	   					 		Type: <bean:write name="type" property="typeDescription"/>
           	   					 	</td>
           	   					 	<td width="15%" align="center" valign="middle">
           	   					 		<table>
           	   					 			<logic:iterate id="wsinfo" name="typemapentry" property="value">
           	   					 			<tr>
				           	   					<td align="center" valign="middle">
				           	   						<bean:define id="printkey" name="wsinfo" property="encryptedPrintKey"/>
				           	   						<%
				           	   							String printurl = request.getContextPath() + "/worksheet.do?action=print&key=" + printkey;
				           	   						%>
				       	   							<a href="#" onclick="showPdf('<%=printurl%>'); return false;">
				       	   								<img src="<%=request.getContextPath()%>/image/printer.jpg" border="0"/>
				       	   							</a>
				           	   					</td>		           	   					 	
           	   					 			</tr>
           	   					 			</logic:iterate>
           	   					 		</table>
           	   					 	</td>
           	   						<td width="35%" class="formValue" valign="top">
       	   								Available worksheets under this type = <bean:write name="type" property="worksheetCount"/>
       	   							</td>	           	   					
           	   					</tr>
           	   				</logic:iterate>
           	   				</table>
           	   			</td>
           	   		</tr> 
           	   		</logic:iterate>   
           	   	</table> 
           </td>
       </tr> 
       </logic:notEmpty>
       <logic:empty name="wiaform" property="alluniquewsdata">
       <tr>
           <td class="errortext_center">Worksheets are not available for the chosen grade and subject</td>
       </tr>        
       </logic:empty>
   </table>  
</html:form>
